﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using Microsoft.Practices.Composite.Events;

namespace EQual.MainModule.Documents.DocumentsDetailViews
{
    /// <summary>
    /// Interaction logic for DocumentsDetailedControl.xaml
    /// </summary>
    public partial class DocumentsDetailedControl : UserControl ,EQual.MainModule.Documents.DocumentsDetailViews.IDocumentDetailedControl
    {

        public event EventHandler<DataEventArgs<DataAccesLayer.Document>> ItemSaved;

        public DocumentsDetailedControl()
        {
            InitializeComponent();
        }

        private DataAccesLayer.Document _activeItem;

        public object ActiveItem
        {
            get { return _activeItem; }
            set
            {
                if (value is DataAccesLayer.Document)
                {
                    _activeItem = value as DataAccesLayer.Document;
                    DataContext = value;
                }
            }
        }

        private void FileIconControl_OnExitingDocument(object sender, RoutedEventArgs e)
        {
            if(ItemSaved != null)
            ItemSaved(this, new DataEventArgs<DataAccesLayer.Document>( ActiveItem as DataAccesLayer .Document ));
        }
    }
}
